import time
from common.unit import AndroidUI


class UseObject:

    def __init__(self):
        self.driver = AndroidUI.get_webdriver()

    # 返回按钮
    # ---------------------基础数据同步--------------------------------------------------------------------
    def data1(self):
        element = self.driver.find_element_by_id("com.bluephone:id/data1")
        return element

    # 本地数据删除
    def date2(self):
        element = self.driver.find_element_by_id("com.bluephone:id/data2")
        return element
    #本地删除二次提示确定按钮
    def del_ok(self):
        element = self.driver.find_element_by_id("com.bluephone:id/md_buttonDefaultPositive")
        return element

    #本地删除二次提示取消按钮
    def del_no(self):
        element = self.driver.find_element_by_id("com.bluephone:id/md_buttonDefaultNegative")
        return element

    # 类型定义
    def data3(self):
        element = self.driver.find_element_by_id("com.bluephone:id/data3")
        return element

    # ---------------回收-----------------------------------------------------------
    # 回收标准
    def recycle_standard(self):
        element = self.driver.find_element_by_id("com.bluephone:id/recycle_manual")
        return element

    # 回收自动
    def recycle_auto(self):
        element = self.driver.find_element_by_id("com.bluephone:id/recycle_auto")
        return element

    # 自动回收设置倒计时长
    def recycle_auto_time(self):
        element = self.driver.find_element_by_id("android:id/input")
        return element

    # 确定按钮
    def ok_button(self):
        element = self.driver.find_element_by_id("com.bluephone:id/md_buttonDefaultPositive")
        return element

    # ----------------------入库-----------------------------------

    # 入库标准
    def store_standard(self):
        element = self.driver.find_element_by_id("com.bluephone:id/store_standard")
        return element

    # 入库自动
    def store_auto(self):
        element = self.driver.find_element_by_id("com.bluephone:id/store_fast")
        return element

    # 输入每箱可装袋数
    def store_number(self):
        element = self.driver.find_element_by_id("android:id/input")
        return element

    # 确定按钮是def ok_button

    # ----------------------出库--------------------

    # 标准出库
    def out_standard(self):
        element = self.driver.find_element_by_id("com.bluephone:id/out_standard")
        return element

    # 一键出库
    def out_auto(self):
        element = self.driver.find_element_by_id("com.bluephone:id/out_fast")
        return element

    # ------------------------复核-----------------------

    # 复核机动
    def free_check(self):
        element = self.driver.find_element_by_id("com.bluephone:id/free_check")
        return element

    # 复核强制
    def force_check(self):
        element = self.driver.find_element_by_id("com.bluephone:id/force_check")
        return element

    # =========================标签===========================================

    # 标签回收打开
    def label_auto(self):
        element = self.driver.find_element_by_id("com.bluephone:id/printTag_true")
        return element

    # 标签回收关闭
    def label_false(self):
        element = self.driver.find_element_by_id("com.bluephone:id/printTag_false")
        return element

    # 返回
    def back_button(self):
        element = self.driver.find_element_by_id("com.bluephone:id/iv_back")
        return element


if __name__ == '__main__':
    u = UseObject()

    from case.lnitial.lnitial_page import LnitialTest

    l = LnitialTest()
    l.useruse()
    time.sleep(1)

    u.data1().click()
    time.sleep(0.2)
    u.date2().click()

    # 回收
    u.recycle_auto().click()
    time.sleep(0.2)
    u.recycle_auto_time().send_keys(3)
    u.ok_button().click()
    u.recycle_standard().click()

    # 入库
    u.store_auto().click()
    time.sleep(0.2)
    u.store_number().send_keys(10)
    time.sleep(0.2)
    u.ok_button().click()
    time.sleep(0.2)
    u.store_standard().click()

    # 出库
    u.out_auto().click()
    u.out_standard().click()

    # 复核
    u.force_check().click()
    u.free_check().click()

    # 标签
    u.label_auto().click()
    u.label_false().click()

    # 返回首页
    u.back_button().click()
